import Vue from 'vue'
import App from './App'
import uView from "uview-ui";
import store from './store'
Vue.use(uView);
Vue.prototype.$store = store
Vue.config.productionTip = false
//Vue.prototype.baseUrl="http://8.141.152.22:8080/dev-api";
//Vue.prototype.domain = 'http://8.141.152.22:8080';
 //Vue.prototype.baseUrl = "http://127.0.0.1:7070/dev-api"
 //Vue.prototype.domain = 'http://127.0.0.1:7070';
Vue.prototype.baseUrl="https://www.runyangnengyuan.net/dev-api";
Vue.prototype.domain = 'https://www.runyangnengyuan.net';
Vue.prototype.appid = "wxaae272ed8bf87e11"

App.mpType = 'app'

const app = new Vue({
	...App,
	store
})

// http拦截器，此为需要加入的内容，如果不是写在common目录，请自行修改引入路径
import httpInterceptor from '@/common/http.interceptor.js'
// 这里需要写在最后，是为了等Vue创建对象完成，引入"app"对象(也即页面的"this"实例)
Vue.use(httpInterceptor, app)

// http接口API集中管理引入部分
import httpApi from '@/common/http.api.js'
Vue.use(httpApi, app)


//import { replaceAll } from '@/common/common.js'
//Vue.prototype.replaceAll = replaceAll

Vue.mixin({
	methods: {
		setData: function(obj, callback) {
			let that = this;
			let keys = [];
			let val, data;
			Object.keys(obj).forEach(function(key) {
				keys = key.split('.');
				val = obj[key];
				data = that.$data;
				keys.forEach(function(key2, index) {
					if (index + 1 == keys.length) {
						that.$set(data, key2, val);
					} else {
						if (!data[key2]) {
							that.$set(data, key2, {});
						}
					}
					data = data[key2];
				})
			});
			callback && callback();
		}
	}
});
Vue.prototype.checkLogin = function() {
	if (!this.$store.state.isLogin) {
		uni.showToast({
		    title: '用户未登录，请登录！',
		    duration: 2000
		});
		uni.reLaunch({
			url: '/pages/myuser/myuser'
		})
		return false;
	}
	return true;
}
app.$mount()
